I am on Windows 10 and I have WSL2 enabled. When I do docker pull ubuntu
followed by docker run ubuntu
, a new ubuntu container with a randomly generated name shows up in my dashboard and it starts for half a second, but then immediately stops. If I press the start button the same behaviour is observed. I tried running these commands from Command Prompt, PowerShell, and my downloaded Ubuntu 18.04 distro (which is also my default WSL2 distro) all with the same result.
How do I fix this?
Also, docker logs <container_name>
doesn't result in anything and double-clicking the container name in the dashboard doesn't show any logs.
Savio Mathew :
A docker container exits when its main process finishes its execution. Now when you check Dockerfile of Ubuntu image you can see the\nCMD ["/bin/bash"] which get execute when we start the container.\nso if you need to run the container in the background you can do\ndocker run -id --name=myubuntu ubuntu \n\nOr you can directly launch the container with an interactive shell using\ndocker run -it --name=myubuntu ubuntu /bin/bash\n",
2020-09-02T06:24:35